package com.dolphin.commons.utils;

import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Element;

/**
 * 描述:
 * ${DESCRIPTION}
 *
 * @author 林平
 * @create 2023-05-27 23:33
 * 个人博客地址：https://www.nonelonely.com
 */
public class WxLoginCacheUtil {

    private static final Cache cache = CacheManager.newInstance().getCache("wxLogin");


    public static String getCacheValue(String key) {
        Element dictEle = cache.get(key);
        if (dictEle != null) {
            return dictEle.getObjectValue().toString();
        }
        return null;
    }

    public static void putCacheValue(String key, String value) {
        cache.put(new Element(key, value));
    }

    public static void putCacheValue(String key, String value, Integer timeToLiveSeconds) {
        cache.put(new Element(key, value, timeToLiveSeconds, timeToLiveSeconds));
    }
}
